package com.blockchain.console.servlets.system.bank;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.console.service.system.BankManage;
import com.blockchain.console.servlets.system.AbstractSystemServlet;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.resource.PromptLevel;
import com.blockchain.framework.service.ServiceSession;
@Right(id = "C_SYS_ADDBANK", name = "银行设置-添加")
public class AddBank extends AbstractSystemServlet{

	private static final long serialVersionUID = 1L;


	@Override
	protected void processPost(final HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		BankManage manage = serviceSession.getService(BankManage.class);
		String name = request.getParameter("name");
		if(name == null ){
			getController().prompt(request, response, PromptLevel.WARRING,
					"银行名称不能为空");
			processGet(request, response, serviceSession);
			return;
		}
		if(manage.isBankName(name)){
			getController().prompt(request, response, PromptLevel.WARRING,
					"银行名称已经存在");
			processGet(request, response, serviceSession);
			return;
		}
		manage.addBank(name);
		sendRedirect(request, response, getController().getURI(request, SearchBank.class));
	}
	
	

}
